package com.qgs.waf.gen;

import java.util.List;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisConnectionUtils;
import org.springframework.data.redis.core.RedisTemplate;

import com.qgs.waf.jedis.JedisUtil;
import com.qgs.waf.jedis.RedisKeys;
import com.qgs.waf.redis.GenRandomData;

public class GenAttackSummaryDate {
	@Autowired
	private static RedisTemplate rt;

	public static void test() {
		ApplicationContext ac = new ClassPathXmlApplicationContext("classpath*:applicationContext*.xml","classpath*:mybatis-*.xml");
		rt = (RedisTemplate) ac.getBean("jedisTemplate");
		RedisConnectionFactory factory = rt.getConnectionFactory();
		RedisConnection redisConnection = RedisConnectionUtils.getConnection(factory);
		redisConnection.openPipeline();
		for (int i = 0; i <1000; i++) {
			redisConnection.zAdd(RedisKeys.ATTACKSUMMARY.getBytes(),Double.parseDouble(String.valueOf(GenRandomData.getRandomScore())),GenRandomData.getCSJson().getBytes());
		}
		List results = redisConnection.closePipeline();
		System.out.println(results);
		redisConnection.close();
		System.out.println("end ......");
	}
	public static void main(String[] args) {
		test();
	}
}
